<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Line;
class LineController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    //
    /*
     * 录入
     */
	public function create(Request $request) {
    	$line = Line::create($request->all());
//     	$user = $request;
    	return response()->json($line);
    }
    
    //获取服务器线路列表
    public function get(Request $request) {
    	
    	$where = array();
    	if ($request->input('province')){
    		$province = $request->input('province');
    		$where['province'] = $province;
    	}
    	if ($request->input('city')){
    		$city = $request->input('city');
    		$where['city'] = $city;
    	}
    	if ($request->input('level')){
    		$level = $request->input('level');
    		$where['level'] = $level;
    	}
    	if ($request->input('carrieroperator')){
    		$carrieroperator = $request->input('carrieroperator');
    		$where['carrieroperator'] = $carrieroperator;
    	}
    	
    	$where['enable_flag'] = 1;
    	
    	$lines = Line::where($where)->get();
    	
    	$return = array(
    			'code' => 0,
    			'msg' => 'OK',
    			'data' => array(
    					'lines'=>$lines
    			)
    	);
        return response()->json($return); 
    	
    }
}
